/*
 * AssemblerApplication1.asm
 *
 *  Created: 2/8/2015 8:18:22 PM
 *   Author: Clinton Bess
 */ 


							;Defining Registers..
.DEF SUM = R0               ;Sum value

.DEF ZERO = R10				;defining zero register
							 
.DEF Val1 = R16             ;Values to add
.DEF Val2 = R17              
.DEF Val3 = R18              
.DEF Val4 = R19              
.DEF Val5 = R20              
.DEF DET = R21              ;used to check for overflow

ADDNUMS:
        CLR ZERO            ;Set Zero
		mov SUM, Zero	    ;clear sum register

		ldi DET, 150	    ;value to check for overflow

        ldi Val1, 59	    ;loading random values
		ldi Val2, 54
		ldi Val3, 59
		ldi Val4, 59
 		ldi Val5, 38

		add SUM, Val1	    ;adding random values to sum register
		add SUM, Val2
		add SUM, Val3
		add SUM, Val4
		add SUM, Val5
		  
		cp SUM, DET			;checking for overflow
		BRLO Overflow		;branches to overflow if sum < 150
		jmp end			    ;jumps to end of program

Overflow:
		sbi PINB, 2		  ;sets pin2 in portb HIGH

end:

.EXIT


